__kernel void prepare(__global int * input,__global int * output, char op, int value) {
	
	const int thid = get_global_id(0);
	
	int i = 0;
	switch(op)
	{
		case '<': if(input[thid] < value) {
						i = 1;
				  } 
				  break;
		case '>': if(input[thid] > value) {
						i = 1;
				  } 
				  break;
		case '=': if(input[thid] == value) {
						i = 1;
				  } 
				  break;	
	}
	output[thid] = i;
}

// sequential verion.
__kernel void getPassedValues(__global int * input, __global int * output, __global int * scan, int length) {

	for(int i = 0; i<length; i++) {
		int index = scan[i];
		output[index] = input[i];
	}
}


// now this kernel works
__kernel void getPassedValuesParallel(__global int * input, __global int * output, __global int * scan, __global int * passed) {

	const int thid = get_global_id(0);
	
	if(passed[thid] == 1) {
		int index = scan[thid];
		output[index] = input[thid];
	}
}